<?php
class BoucleConditionnelleVariable extends PexElement{
	public $nom;
	public $contenu;

    function __construct($nom)
    {
        $this->nom = $nom;
        $this->contenu = array();
    }

    function type()
    {
        return PexToken::TYPE_BOUCLE_COND_VARIABLE;
    }

    function evaluer(&$substitutions = array())
    {
		$idx = isset($substitutions['#'.$this->nom]) && $substitutions['#'.$this->nom] != '' ? 0 : 1;

		return $this->contenu[$idx]->evaluer($substitutions);
    }

    function ajouter($data)
    {
        if (DEBUG_EVAL) { Analyse::echo_debug("BoucleConditionnelleVariable ajout:", $data); }

        $this->contenu[] = $data;
    }

    function imprimer()
    {
        Analyse::echo_debug("[SI $this->nom]");
        if ($this->contenu[0]) $this->contenu[0]->imprimer();
        Analyse::echo_debug("[SINON $this->nom]");
        if ($this->contenu[1]) $this->contenu[1]->imprimer();
        Analyse::echo_debug("[FINSI $this->nom]");
    }
}
?>